<template>
  <el-dialog title="配置" :visible.sync="dialogVisible" :close-on-click-modal="false" @close="onClose" append-to-body width="30%" v-draggable>
    <el-form ref="form" :model="form" label-width="100px" class="mt-2" :rules="rules">
      <el-form-item label="大于等于" prop="startNumber">
        <el-input v-model="form.startNumber" placeholder="请输入大于等于" />
      </el-form-item>
      <el-form-item label="小于" prop="endNumber">
        <el-input v-model="form.endNumber" placeholder="请输入小于" />
      </el-form-item>
      <el-form-item label="描述" prop="showName">
        <el-input v-model="form.showName" placeholder="请输入描述" />
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button type="primary" @click="onSave()">保 存</el-button>
      <el-button @click="onClose()">取 消</el-button>
    </span>
  </el-dialog>
</template>

<script>
export default {
  data() {
    return {
      viewIndex: null,
      form: {
        startNumber: '',
        endNumber: '',
        childrenDeviceCodeFZ: '',
        showName: ''
      },
      dialogVisible: false,
      rules: {
        startNumber: { required: true, message: '请输入大于等于', trigger: 'blur' },
        endNumber: { required: true, message: '请输入小于', trigger: 'blur' },
        showName: { required: true, message: '请输入描述', trigger: 'blur' }
      }
    }
  },
  methods: {
    onSave() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          let obj = {
            viewIndex: this.viewIndex,
            startNumber: this.form.startNumber,
            endNumber: this.form.endNumber,
            showName: this.form.showName
          }
          this.$parent.$parent.tableData.push(obj)
          this.onClose()
        }
      })
    },
    onClose() {
      this.$refs['form'].resetFields()
      this.dialogVisible = false
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep .el-dialog {
  border-radius: 8px;

  .el-dialog__body {
    max-height: 65vh;
    overflow-y: auto;
    padding: 10px 20px;
  }

  .el-dialog__footer {
    text-align: center !important;
  }
}

::v-deep .el-dialog__header {
  border-radius: 8px 8px 0 0;
  background-color: #e6e6e6;
}

.ml-3 {
  margin-left: 12px;
}

.my_span {
  font-size: 16px;
}

// ::v-deep .el-table {

//     tr th {
//         background-color: #e6e6e6;
//         border-right: none;
//     }
// }
</style>
